/**
 * [spring-jpa-distributed-transaction] in.choich.controllers.JustTestTranController.java
 * 
 * created at 2016年11月1日 by kevin_zhu
 */
package in.choich.controllers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import in.choich.services.JustTestTranService;

/**
 * @author kevin_zhu
 *
 */

@RestController
@RequestMapping("/tran")
public class JustTestTranController {

	private static final Logger log = LoggerFactory.getLogger(JustTestTranController.class);
	
	@Autowired
	private JustTestTranService studentService;
	
	/**
	 * 
	 */
	public JustTestTranController() {
		// TODO Auto-generated constructor stub
	}
	
	@RequestMapping("/multidatatran")
	public String multiDataTran(){
		String rv = "success multidataTransource";
		boolean isSucc = true;
		try {
			log.info("Now Excuting for multidataTransource...");
			isSucc = studentService.multiDataSourceTransaction();
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			log.info("Sorry Ex : "+e.getMessage());
			isSucc = false;
			rv = "failed multidataTransource";
		}
		return isSucc?"success multidataTransource":"failed multidataTransource";
//		return rv;
	}

}
